﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using DIS.Infrastructure.Entities.Repository;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.Entity.Migrations;
using System.Data.Entity.Infrastructure;
using System.Web;
using System.Text.RegularExpressions;

namespace DIS.Infrastructure.Entities
{
    public class Context : DbContext
    {
       // public Context() : this(GetContextName())  { }
        public Context()
            : base("name=Context")
        {
            Database.SetInitializer<Context>(null);
        }
        public DbSet<T_User> User { get; set; }
        public DbSet<T_CityTaxi> CityTaxi { get; set; }
        public DbSet<T_CityTaxiDetail> CityTaxiDetail { get; set; }
        public DbSet<T_HotelFee> HotelFee { get; set; }
        public DbSet<T_HotelFeeDetail> HotelFeeDetail { get; set; }
        public DbSet<T_LongHaul> LongHaul { get; set; }
        public DbSet<T_LongHaulDetail> LongHaulDetail { get; set; }
        public DbSet<T_FinancialPeriod> FinancialPeriod { get; set; }
        public DbSet<T_Project> Project { get; set; }
       
       
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();//移除复数表名的契约
        }
        //private static string GetContextName()
        //{
        //    string host = HttpContext.Current.Request.Url.Host;
        //    string contextName = "name=Context";
        //    if(new Regex("([A-Za-z0-9\\-]+\\.){2}com").IsMatch(host))
        //    {
        //        contextName = "name=" + host.Substring(0, host.IndexOf('.'));
        //    }
        //    return contextName;
        //}
    }
}
